package edu.ccut.titan.tag.report.servlet;

import java.util.ArrayList;
import java.util.List;

import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PiePlot3D;
import org.jfree.data.general.DefaultPieDataset;
import org.jfree.util.Rotation;


import net.sf.jasperreports.charts.design.JRDesignPiePlot;
import net.sf.jasperreports.engine.JRDefaultScriptlet;
import net.sf.jasperreports.engine.JRScriptletException;
import net.sf.jasperreports.engine.design.JRDesignChart;
import net.sf.jasperreports.renderers.JCommonDrawableRenderer;

public class A extends JRDefaultScriptlet {

	/**
	 * 
	 */
	public void afterReportInit() throws JRScriptletException {
		DefaultPieDataset dataset = new DefaultPieDataset();
		dataset.setValue("Java", new Double(43.2));
		dataset.setValue("Visual Basic", new Double(10.0));
		dataset.setValue("C/C++", new Double(17.5));
		dataset.setValue("PHP", new Double(32.5));
		dataset.setValue("Perl", new Double(1.0));

		// JFreeChart chart1 = ChartFactory.
		JFreeChart chart = ChartFactory.createPieChart3D("Pie Chart 3D Demo 1",
				dataset, true, true, false);
		JRDesignChart chart12 = new JRDesignChart(null, (byte) 0);
		JRDesignPiePlot designPiePlot = (JRDesignPiePlot) chart12.getPlot();
		List list = new ArrayList();
		designPiePlot.setSeriesColors(list );
		PiePlot3D plot = (PiePlot3D) chart.getPlot();
		plot.setStartAngle(290);
		plot.setDirection(Rotation.CLOCKWISE);
		plot.setForegroundAlpha(0.5f);
		plot.setNoDataMessage("No data to display");

		/*   */
		this.setVariableValue("Chart", new JCommonDrawableRenderer(chart));
	}
}
